using System.ComponentModel.DataAnnotations;

namespace WorkflowApi.Models
{
    // 工作流定义模型
    public class WorkflowDefinition
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Description { get; set; } = string.Empty;
        public string Version { get; set; } = "1.0";
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        public bool IsActive { get; set; } = true;
        public List<WorkflowStep> Steps { get; set; } = new();
    }

    // 工作流步骤模型
    public class WorkflowStep
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Type { get; set; } = string.Empty; // Approval, Parallel, Condition, etc.
        public int Order { get; set; }
        public List<string> Approvers { get; set; } = new(); // 审批人ID列表
        public List<string> CcUsers { get; set; } = new(); // 抄送人ID列表
        public string? Condition { get; set; } // 条件表达式
        public Dictionary<string, object> Properties { get; set; } = new(); // 额外属性
    }

    // 工作流实例模型
    public class WorkflowInstance
    {
        public string Id { get; set; } = string.Empty;
        public string DefinitionId { get; set; } = string.Empty;
        public string Status { get; set; } = "Running"; // Running, Completed, Suspended
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        public DateTime? CompletedAt { get; set; }
        public string CreatedBy { get; set; } = string.Empty;
        public Dictionary<string, object> Data { get; set; } = new();
    }

    // 工作流任务模型
    public class WorkflowTask
    {
        public string Id { get; set; } = string.Empty;
        public string InstanceId { get; set; } = string.Empty;
        public string StepId { get; set; } = string.Empty;
        public string Assignee { get; set; } = string.Empty;
        public string Status { get; set; } = "Pending"; // Pending, Approved, Rejected, Delegated
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        public DateTime? CompletedAt { get; set; }
        public string? Comment { get; set; }
        public string? Action { get; set; } // Approve, Reject, Delegate, AddSign
    }

    // API请求模型
    public class CreateWorkflowRequest
    {
        [Required]
        public string Name { get; set; } = string.Empty;
        public string Description { get; set; } = string.Empty;
        public List<WorkflowStep> Steps { get; set; } = new();
    }

    public class StartWorkflowRequest
    {
        [Required]
        public string DefinitionId { get; set; } = string.Empty;
        public Dictionary<string, object> Data { get; set; } = new();
    }

    public class ApproveTaskRequest
    {
        [Required]
        public string TaskId { get; set; } = string.Empty;
        public string? Comment { get; set; }
        public string Action { get; set; } = "Approve"; // Approve, Reject, Delegate, AddSign
        public string? DelegateTo { get; set; } // 委托给谁
        public List<string>? AddSignUsers { get; set; } // 加签用户列表
    }

    // 用户和组织模型
    public class User
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Email { get; set; } = string.Empty;
        public string DepartmentId { get; set; } = string.Empty;
        public List<string> Roles { get; set; } = new();
    }

    public class Department
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string? ParentId { get; set; }
        public string ManagerId { get; set; } = string.Empty;
    }

    public class Role
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Description { get; set; } = string.Empty;
    }
} 